from websocket.msghandler import MsgContext, MessageType


class StatisticalHandler:
    @classmethod
    def handle(cls, message):
        indicator_data = message['indicator_data']
        problem_datas_length = len(MsgContext.multiple_populations)
        algorithms_datas_length = len(MsgContext.multiple_populations[0])
        statistical_type = message['statistical_type']
        MsgContext.statistical_result(algorithms_datas_length, problem_datas_length, indicator_data, statistical_type)
        MsgContext.task_complete_return(MessageType.MULTI_TASK_COMPLETED)
